var map,mposctl,vectors, geojson,markers,selectControl;
var selectedFeature;
//Init
map = new OpenLayers.Map('floor7');
layer = new OpenLayers.Layer.Image(
    "floor7",
    "floor7.jpg",
    new OpenLayers.Bounds(-1091,-282,1091,282),
    new OpenLayers.Size(2182,564)
);
map.addLayer(layer);
map.zoomToMaxExtent();
var featurecollection = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_94",
            "properties": {
                "name": "Biomedical & Molecular BT Lab",
                "description": "Molecular Lab of Biotechnology"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -1079,
                            259
                        ],
                        [
                            -801,
                            259
                        ],
                        [
                            -801,
                            46
                        ],
                        [
                            -1079,
                            45
                        ],
                        [
                            -1079,
                            259
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_116",
            "properties": {
                "name": "Cell Biotechnology Lab",
                "description": "Cell lab of BT School"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -1080,
                            42
                        ],
                        [
                            -802,
                            41
                        ],
                        [
                            -800,
                            -173
                        ],
                        [
                            -1081,
                            -174
                        ],
                        [
                            -1080,
                            42
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_140",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -683,
                            260
                        ],
                        [
                            -562,
                            260
                        ],
                        [
                            -563,
                            75
                        ],
                        [
                            -683,
                            75
                        ],
                        [
                            -683,
                            260
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_162",
            "properties": {
                "name": "Office of Finance",
                "description": "academic settings services related to school fees"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -558,
                            261
                        ],
                        [
                            -379,
                            258
                        ],
                        [
                            -381,
                            75
                        ],
                        [
                            -558,
                            74
                        ],
                        [
                            -558,
                            261
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_186",
            "properties": {
                "name": "Office of Facilities Management",
                "description": "concerning facilities affair"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -376,
                            261
                        ],
                        [
                            -196,
                            259
                        ],
                        [
                            -195,
                            74
                        ],
                        [
                            -374,
                            74
                        ],
                        [
                            -376,
                            261
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_208",
            "properties": {
                "name": "office of International Relations and R &D Management",
                "description": ""
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -191,
                            258
                        ],
                        [
                            0,
                            259
                        ],
                        [
                            -1,
                            72
                        ],
                        [
                            -190,
                            74
                        ],
                        [
                            -191,
                            258
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_230",
            "properties": {
                "name": "Rector 's office",
                "description": "the personel room of rector"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            6,
                            258
                        ],
                        [
                            181,
                            258
                        ],
                        [
                            181,
                            76
                        ],
                        [
                            4,
                            74
                        ],
                        [
                            6,
                            258
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_254",
            "properties": {
                "name": "Office of personal Administration",
                "description": ""
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            186,
                            262
                        ],
                        [
                            380,
                            259
                        ],
                        [
                            379,
                            75
                        ],
                        [
                            186,
                            74
                        ],
                        [
                            186,
                            262
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_276",
            "properties": {
                "name": "Meeting room",
                "description": "room for discussion"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            384,
                            262
                        ],
                        [
                            568,
                            261
                        ],
                        [
                            571,
                            74
                        ],
                        [
                            383,
                            75
                        ],
                        [
                            384,
                            262
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_300",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            574,
                            260
                        ],
                        [
                            674,
                            260
                        ],
                        [
                            676,
                            73
                        ],
                        [
                            572,
                            73
                        ],
                        [
                            574,
                            260
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_322",
            "properties": {
                "name": "Department of Business administration",
                "description": "the working office of BA school"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            822,
                            262
                        ],
                        [
                            1088,
                            261
                        ],
                        [
                            1088,
                            42
                        ],
                        [
                            822,
                            40
                        ],
                        [
                            822,
                            262
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_342",
            "properties": {
            },
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [
                        823,
                        35
                    ],
                    [
                        1086,
                        34
                    ],
                    [
                        1085,
                        -167
                    ],
                    [
                        1085,
                        33
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_366",
            "properties": {
                "name": "Office of Academic Affair",
                "description": "concerning academic settings related to schedules, announcements..."
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            821,
                            36
                        ],
                        [
                            1086,
                            35
                        ],
                        [
                            1087,
                            -169
                        ],
                        [
                            821,
                            -169
                        ],
                        [
                            821,
                            36
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_390",
            "properties": {
                "name": "Stair_7",
                "description": "Stair of Floor 7"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            669,
                            -177
                        ],
                        [
                            751,
                            -176
                        ],
                        [
                            751,
                            -251
                        ],
                        [
                            673,
                            -251
                        ],
                        [
                            669,
                            -177
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_414",
            "properties": {
                "name": "Elevator_7",
                "description": "Elevator of Floor 7"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            528,
                            -52
                        ],
                        [
                            674,
                            -53
                        ],
                        [
                            674,
                            -168
                        ],
                        [
                            526,
                            -168
                        ],
                        [
                            528,
                            -52
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_436",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            337,
                            -52
                        ],
                        [
                            521,
                            -53
                        ],
                        [
                            522,
                            -168
                        ],
                        [
                            337,
                            -169
                        ],
                        [
                            337,
                            -52
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_458",
            "properties": {
                "name": "Cleaning Services",
                "description": "provide cleaning services"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            110,
                            -54
                        ],
                        [
                            335,
                            -55
                        ],
                        [
                            336,
                            -166
                        ],
                        [
                            107,
                            -168
                        ],
                        [
                            110,
                            -54
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_494",
            "properties": {
                "name": "Vice rector's office",
                "description": ""
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -116,
                            -53
                        ],
                        [
                            103,
                            -52
                        ],
                        [
                            105,
                            -165
                        ],
                        [
                            -116,
                            -167
                        ],
                        [
                            -115,
                            -167
                        ],
                        [
                            -116,
                            -165
                        ],
                        [
                            -114,
                            -165
                        ],
                        [
                            -117,
                            -165
                        ],
                        [
                            -116,
                            -53
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_516",
            "properties": {
                "name": "Vice Rector's office",
                "description": "the working office of vice rector"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -331,
                            -53
                        ],
                        [
                            -121,
                            -54
                        ],
                        [
                            -122,
                            -167
                        ],
                        [
                            -331,
                            -169
                        ],
                        [
                            -331,
                            -53
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_538",
            "properties": {
                "name": "Vice Rector's office",
                "description": ""
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -539,
                            -53
                        ],
                        [
                            -336,
                            -54
                        ],
                        [
                            -335,
                            -168
                        ],
                        [
                            -540,
                            -167
                        ],
                        [
                            -539,
                            -53
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_562",
            "properties": {
                "name": "Stair_7",
                "description": "Stair of Floor 7"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -754,
                            -178
                        ],
                        [
                            -694,
                            -177
                        ],
                        [
                            -693,
                            -248
                        ],
                        [
                            -752,
                            -249
                        ],
                        [
                            -754,
                            -178
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_584",
            "properties": {
                "name": "Elevator_7",
                "description": "Elevator of Floor 7"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -686,
                            -51
                        ],
                        [
                            -542,
                            -52
                        ],
                        [
                            -544,
                            -168
                        ],
                        [
                            -688,
                            -169
                        ],
                        [
                            -686,
                            -51
                        ]
                    ]
                ]
            }
        }
    ]
}
geojson = new OpenLayers.Format.GeoJSON();
vectors = new OpenLayers.Layer.Vector();
selectControl= new OpenLayers.Control.SelectFeature(vectors,
    {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
map.addLayer(vectors);
vectors.addFeatures(geojson.read(featurecollection));
map.addControl(selectControl);
selectControl.activate();
function onPopupClose(){selectControl.unselect(selectedFeature);};
function onFeatureSelect(feature){
    selectedFeature = feature;
    popup = new OpenLayers.Popup.FramedCloud(feature.id + "pop", feature.geometry.getBounds().getCenterLonLat(),null,"<div style='font-size:.8em'>Room: " + feature.attributes.name + "<br />Description: " + feature.attributes.description + "</div>",null, true, onPopupClose);
    feature.popup = popup;
    map.addPopup(popup);
}
function onFeatureUnselect(feature){
    map.removePopup(feature.popup);
    feature.popup.destroy();
    feature.popup = null;
}
